<script setup>
import { uploadAvatar } from '@/api/user.js'
defineOptions({
  name: 'uploadAvatar'
})
defineProps(['userInfo'])
const afterRead = (file) => {
  let fd = new FormData()
  fd.append('avatar', file.file)
  uploadAvatar(fd)
}
</script>

<template>
  <div class="d-flex justify-content-center my-3">
    <van-uploader :after-read="afterRead" :accept="'image/*'">
      <van-icon :name="userInfo ? userInfo.avatar_url : 'user-o'" :size="60" />
    </van-uploader>
  </div>
</template>

<style scoped lang="scss"></style>
